#include "tcl_wrapper.h"

int Tcl_AppInit(Tcl_Interp *interp) {
    
    if (Tcl_Init(interp) == TCL_ERROR) {
        return TCL_ERROR;
    }

    
    Tcl_SetVar(interp, "thread_num", "1", 0);    
    //Tcl_SetVar(interp, "tcl_rcFileName", "~/.ktclshrc", TCL_GLOBAL_ONLY);
    Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY);
    Tcl_SetVar(interp, "TDM_XFREQ", "2", TCL_GLOBAL_ONLY);
    Tcl_SetVar(interp, "TDM_YFREQ", "2", TCL_GLOBAL_ONLY);
    Tcl_SetVar(interp, "TDM_DIS", "1", TCL_GLOBAL_ONLY);

    // CG3D
    Tcl_CreateCommand(interp, "CG3D_INIT",cg3d_init,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "CG3D_FLUSH",cg3d_FlushCMDs,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "CG3D_DISPLAY",cg3d_Display,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "CG3D_ADDCLB",cg3d_AddCLB,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "CG3D_SETCLBLOC",cg3d_SetCLBLoc,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "CG3D_ADDEDGE",cg3d_AddEdge,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "CG3D_HILITCLB",cg3d_hilitCLB,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "CG3D_DRAWLINE",cg3d_drawLine,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "CG3D_UPDATELOC",cg3d_updateLoc,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "CG3D_ADD_NETSEG",cg3d_add_netseg,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    
    // BASE
    Tcl_CreateCommand(interp, "bs_init_place_env",base_init_placement_env,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "base_init_tdm_env",base_init_tdm_env,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "bs_addcell",base_AddCell,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "bs_set_cell_loc",base_SetCellLoc,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "bs_addedge",base_AddEdge,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "bs_report_stat",base_ReportStat,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "bs_print_network",base_printNetwork,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "bs_print_cell",base_printcell,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "bs_random_place",base_randomly_place,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    
    // FORCE-DIRECT
    Tcl_CreateCommand(interp, "fd_place",fd_place,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    Tcl_CreateCommand(interp, "fd_compress",fd_compress,
                    (ClientData)NULL, (Tcl_CmdDeleteProc *)NULL);
    return TCL_OK;
}

